import Vue from 'vue'
import Router from 'vue-router'
import Header from "@/components/header.vue";
import index from '@/views/index.vue'
import Article from '@/views/article.vue'
import Login3D from '@/views/login3d.vue'
import  Integrating from '@/views/timeline.vue'
Vue.use(Router)

const router = new Router({
  routes: [
    // {
    //   path: '/',
    //   redirect: '/login',
    // },
    {
      path: '/',
      redirect: '/login3d',

    },
    {
      path: '/',
      component: index,
      children: [{
        path: 'routeArticle',
        name: 'routeArticle',
        component: Article,
        meta: {
          title: '文章库'
        }
      },
      {
        path: 'Integrating',
        name: 'Integrating',
        component: Integrating,
        meta: {
          title: '合成平台'
        }
      },
      ],

    },

    {
      path: '/login3d',
      name: 'login3d',
      component: Login3D,
      meta: {
        title: '登录页'
      }
    },
  ]
})
// router.beforeEach((to, from, next) => {

//   // if (from.path == '/' && to.path != '/login') {
//   //   console.log(123)
//   //   return false
//   // } else {
//   //   next()
//   // }
//   // if (from.path == '/login' && from.query.autu) {
//   //   next()
//   // } else { return { name: '/login' } }
//   // if (from.path != '/login') {
//   //   next()
//   // }
//   console.log(sessionStorage.getItem('autu'))
//   if (sessionStorage.getItem('autu') != 'true' && to.name !== 'login') {
//     return { name: 'login' }
//   }
//   else { next() }



// })
router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  if (localStorage.getItem('autu') != 'true' && to.name !== 'login3d') {
    next({ name: 'login3d' })
  }
  else {
    document.title = to.meta.title
    next()
  }
})
export default router